using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using BoOnce.Components;
using BoOnce.GameLogic;
using BoOnce.Helpers;
using BoOnce.Steps;
using BoOnce.Core.Components;
using BoOnce.Core;

namespace BoOnce.Steps
{
    class InitGameStep : Step
    {
        public InitGameStep(Game game)
            : base(game,"Init Game Loop")
        {
            BackgroundTaskComponent btComponent = new BackgroundTaskComponent(Game);
            btComponent.UpdateOrder = Priority.BACKGROUND_TASK_COMPONENT;
            btComponent.Enabled = true;

            DrawableEntityComponent deComponent = new DrawableEntityComponent(Game);
            deComponent.UpdateOrder = Priority.DRAWABLE_ENTITY_COMPONENT;
            deComponent.Enabled = true;

            PlayerActionComponent paComponent = new PlayerActionComponent(Game);
            paComponent.UpdateOrder = Priority.PLAYER_ACTION_COMPONENT;
            paComponent.Enabled = true;

            CameraComponent cameraComponent = new CameraComponent(Game, new CameraConfig());
            cameraComponent.UpdateOrder = Priority.CAMERA_COMPONENT;
            cameraComponent.Enabled = true;

            FPSComponent fpsComponent = new FPSComponent(Game);
            fpsComponent.UpdateOrder = Priority.FPS_COMPONENT;
            fpsComponent.Enabled = true;

            Game.Services.AddService(typeof(BackgroundTaskComponent), btComponent);
            Game.Services.AddService(typeof(DrawableEntityComponent), deComponent);
            Game.Services.AddService(typeof(PlayerActionComponent), paComponent);
            Game.Services.AddService(typeof(CameraComponent), cameraComponent);
            Game.Services.AddService(typeof(FPSComponent), fpsComponent);

            Game.Components.Add(btComponent);
            Game.Components.Add(deComponent);
            Game.Components.Add(paComponent);
            Game.Components.Add(cameraComponent);
            Game.Components.Add(fpsComponent);
        }

        public override void Update(GameTime gameTime)
        {
            //StepTransitionComponent.GoTo(new Credits(Game));
            StepTransitionComponent.GoTo(new MenuStep(Game));
            Logger.WriteInfo("==================================");
            Logger.WriteInfo("");
            base.Update(gameTime);
        }

    }
}
